<div class="form">

    <? $this->widget('ext.EAjaxUpload.EAjaxUpload',
    array(
            'id'=>'uploadFile',
            'config'=>array(
                   'action'=>'/site/upload',
                   'allowedExtensions'=>array("jpg","jpeg","gif","png"),//array("jpg","jpeg","gif","exe","mov" and etc...
                   'sizeLimit'=>8*1024*1024,// maximum file size in bytes
                   'minSizeLimit'=>1*1024,// minimum file size in bytes
                   'multiple'=>true,
                   //'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
                   //'messages'=>array(
                   //                  'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
                   //                  'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
                   //                  'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",
                   //                  'emptyError'=>"{file} is empty, please select files again without it.",
                   //                  'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
                   //                 ),
                   //'showMessage'=>"js:function(message){ alert(message); }"
                  )
    )); ?>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'item-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<div class="row" style='height:200px; overflow-y:scroll;'>
	<?
		$features = $model->features;
		foreach($features as $feature){
			$featuresarray[] = $feature->id;
		}
		if(!isset($featuresarray)) $featuresarray = array();
		$allfeatures = Feature::model()->findall();
		foreach($allfeatures as $allfeature){
			$allfeaturesarray[$allfeature->id] = $allfeature->title;
		}
		echo CHtml::checkBoxList('features',$featuresarray,$allfeaturesarray);
	?>
	</div>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'show'); ?>
		<?php echo $form->checkBox($model,'show'); ?>
		<?php echo $form->error($model,'show'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'avalible'); ?>
		<?php echo $form->checkBox($model,'avalible'); ?>
		<?php echo $form->error($model,'avalible'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'manufacturer'); ?>
		<?php echo $form->error($model,'manufacturer'); ?>
		<? if(Manufacturer::model()->exists()){?>
		<?
			echo $form->dropDownList($model,'manufacturer', CHtml::listData(Manufacturer::model()->findAll(), 'id', 'title'), array('empty'=>' Выберите производителя'));
		?>
		Вы можете перети в <? echo CHtml::link('управление', Yii::app()->createUrl("manufacturer")); ?> производителями.
		<?}else{?>
			Производители не найдены. Вы можете <? echo CHtml::link('добавить', Yii::app()->createUrl("manufacturer/create")); ?> производителей.
		<?}?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'category'); ?>
		<?php echo $form->error($model,'category'); ?>
		<? if(Category::model()->exists()){?>
		<?
			echo $form->dropDownList($model,'category', CHtml::listData(Category::model()->findAll('parent != 0'), 'id', 'title'), array('empty'=>' Выберите категорию'))
		?>
		Вы можете перейти в <? echo CHtml::link('управление', Yii::app()->createUrl("category")); ?> категориями.
		<?}else{?>
			Категории не найдены. Вы можете <? echo CHtml::link('добавить', Yii::app()->createUrl("category/create")); ?> категории.
		<?}?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

    <div class="row">
   		<?php echo $form->labelEx($model,'alt_title'); ?>
   		<?php echo $form->textField($model,'alt_title',array('size'=>60,'maxlength'=>255)); ?>
   		<?php echo $form->error($model,'alt_title'); ?>
   	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'permalink'); ?>
		<?php echo $form->textField($model,'permalink',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'permalink'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'price'); ?>
		<?php echo $form->textField($model,'price'); ?>
		<?php echo $form->error($model,'price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'old_price'); ?>
		<?php echo $form->textField($model,'old_price'); ?>
		<?php echo $form->error($model,'old_price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
		<?php echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'description'); ?>
	</div>

    <div class="row">
   		<?php echo $form->labelEx($model,'alt_description'); ?>
   		<?php echo $form->textArea($model,'alt_description',array('rows'=>6, 'cols'=>50)); ?>
   		<?php echo $form->error($model,'alt_description'); ?>
   	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'alt_keywords'); ?>
		<?php echo $form->textField($model,'alt_keywords',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'alt_keywords'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->